package com.dingding.service.user.core.order.dao.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.dingding.facade.user.dto.order.ReqGetAllCityWideUserDTO;
import com.dingding.facade.user.dto.order.ResGetAllCityWideUserDTO;
import com.dingding.service.user.core.dao.IUserLoginDao;
import com.dingding.service.user.core.order.dao.IOrderUserDao;
import com.dingding.service.user.core.order.sql.OrderUserSQL;

/**
 * 
 * @ClassName: OrderUserDaoImpl 
 * @Description: 订单业务用户数据操作 
 * @author CHEHAUNBO 
 * @date 2016年8月5日 下午4:31:34
 * 
 */
@Component("orderUserDao")
public class OrderUserDaoImpl implements IOrderUserDao {

	private static Logger log = Logger.getLogger(OrderUserDaoImpl.class);

	@Resource(name = "userLoginDao")
	private IUserLoginDao userLoginDao;

	/**
	 * 
	 * 获取所有的同城用户
	 * 
	 * @Title: getAllCityWideUserByCity 
	 * @author CHEHAUNBO
	 * @since V2.4.0
	 * 
	 */
	@Override
	@SuppressWarnings("all")
	@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)
	public List<ResGetAllCityWideUserDTO> getAllCityWideUserByCity(ReqGetAllCityWideUserDTO reqGetAllCityWideUserDTO) {

		List<ResGetAllCityWideUserDTO> cityWideUserDTOs = new ArrayList<ResGetAllCityWideUserDTO>();

		try {
			cityWideUserDTOs = (List<ResGetAllCityWideUserDTO>) userLoginDao.listSqlToCustomBean(
					OrderUserSQL.GET_PUSH_USER_INFO(reqGetAllCityWideUserDTO.getPublishType()),
					ResGetAllCityWideUserDTO.class, reqGetAllCityWideUserDTO.getCity() + "%",
					reqGetAllCityWideUserDTO.getLoginId());
		} catch (Exception e) {
			log.error("查询同城用户出现异常！", e);
		}

		return cityWideUserDTOs;

	}

}
